import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed 
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },
  {
    path: '/privilege',
    component: Layout,
    redirect: '/privilege/List',
    name: 'Privilege',
    meta: { title: '个人管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'privilegeList',
        component: () => import('@/views/BasePrivilege/List'),
        meta: { title: '个人列表' }
      }
    ]
  },
  {
    path: '/xiaoxiao',
    component: Layout,
    redirect: '/xiaoxiao/List',
    name: 'xiaoxiao',
    meta: { title: '覃媛连', icon: 'example' },
    children: [
      {
        path: 'basefile',
        name: 'BaseFileList',
        component: () => import('@/views/BaseFile/List'),
        meta: { title: '基本文件管理' }
      },
      {
        hidden:true,//有，但是不在菜单中显示
        path: 'baseFileForm',
        name: 'baseFileForm',
        component: () => import('@/views/BaseFile/Form'),
        meta: { title: '基本文件表单' }
      },
      {
        path: 'basePrivilege',
        name: 'BasePrivilegeList',
        component: () => import('@/views/BasePrivilege/List'),
        meta: { title: '权限管理' }
      },
      {
        hidden:true,//有，但是不在菜单中显示
        path: 'basePrivilegeForm',
        name: 'basePrivilegeForm',
        component: () => import('@/views/BasePrivilege/Form'),
        meta: { title: '权限管理表单' }
      },
      {
        path: 'baseLog',
        name: 'logList',
        component: () => import('@/views/BaseLog/List'),
        meta: { title: '日志管理' }
      },
      {
        hidden:true,//有，但是不在菜单中显示
        path: 'baseLogForm',
        name: 'logList',
        component: () => import('@/views/BaseLog/Form'),
        meta: { title: '日志表单' }
      },
      {   
        path: 'redwinerecognition',
        name: 'RedWineRecognition_index',
        component: () => import('@/views/RedWineRecognition/index'),
        meta: { title: '红酒识别' }
      }
    ]
  },

  {
    path: '/xiaoke',
    component: Layout,
    redirect: '/xiaoke/baseUser',
    name: 'xiaoke',
    meta: { title: '丁艳', icon: 'example' },
    children: [
      {
        path: 'baseUser',
        name: 'BaseUserList',
        component: () => import('@/views/BaseUser/List'),
        meta: { title: '基础用户列表' }
      },
      {
        path: 'baseRole',
        name: 'BaseRoleList',
        component: () => import('@/views/BaseRole/List'),
        meta: { title: '基础角色列表' }
      },
      {
        path: 'callLog',
        name: 'CallLogList',
        component: () => import('@/views/CallLog/List'),
        meta: { title: '识别记录列表' }
      },
      {
        hidden:true,
        path: 'baseUser_form',
        name: 'BaseUserList_Form',
        component: () => import('@/views/BaseUser/Form'),
        meta: { title: '基础用户表单' }
      },
      {
        hidden:true,
        path: 'baseRole_form',
        name: 'BaseRoleList_Form',
        component: () => import('@/views/BaseRole/Form'),
        meta: { title: '基础角色表单' }
      },
      {
        hidden:true,
        path: 'callLog_form',
        name: 'CallLogList_Form',
        component: () => import('@/views/CallLog/Form'),
        meta: { title: '识别记录表单' }
      },
      {   
        path: 'landmarkrecognition',
        name: 'LandMarkRecognition_index',
        component: () => import('@/views/LandMarkRecognition/index'),
        meta: { title: '地标识别' }
      }

    ]
  },

  {
    path: '/ljc',
    component: Layout,
    redirect: '/ljc/module',
    name: 'ljc',
    meta: { title: '罗俊财', icon: 'example' },
    children: [
      {
        path: 'module',
        name: 'ModuleList',
        component: () => import('@/views/Module/List'),
        meta: { title: '模块列表' }
      },
      {
        path: 'rolePrivilege',
        name: 'RolePrivilegeList',
        component: () => import('@/views/RolePrivilege/List'),
        meta: { title: '角色特权列表' }
      },
      {
        path: 'userRole',
        name: 'UserRoleList',
        component: () => import('@/views/UserRole/List'),
        meta: { title: '用户角色列表' }
      },
      {
        hidden:true,
        path: 'module_form',
        name: 'ModuleList_Form',
        component: () => import('@/views/Module/Form'),
        meta: { title: '模块表单' }
      },
      {
        hidden:true,
        path: 'rolePrivilege_form',
        name: 'RolePrivilegeList_Form',
        component: () => import('@/views/RolePrivilege/Form'),
        meta: { title: '角色特权表单' }
      },
      {
        hidden:true,
        path: 'userRole_form',
        name: 'UserRoleList_Form',
        component: () => import('@/views/UserRole/Form'),
        meta: { title: '用户角色表单' }
      }
    ]
  },


  {
    path: '/rongxuegang',
    component: Layout,
    redirect: '/rxg/category',
    name: 'rxg',
    meta: { title: '容学刚', icon: 'example' },
    children: [
      {
        path: 'category',
        name: 'CategoryList',
        component: () => import('@/views/Category/List'),
        meta: { title: '种类列表' }
      },
      {
        path: 'comment',
        name: 'CommentList',
        component: () => import('@/views/Comment/List'),
        meta: { title: '注释列表' }
      },
      {
        path: 'dataset',
        name: 'DatasetList',
        component: () => import('@/views/Dataset/List'),
        meta: { title: '数据集列表' }
      },
      {
        hidden:true,
        path: 'category_form',
        name: 'CategoryList_Form',
        component: () => import('@/views/Category/Form'),
        meta: { title: '种类表单' }
      },
      {
        hidden:true,
        path: 'comment_form',
        name: 'CommentList_Form',
        component: () => import('@/views/Comment/Form'),
        meta: { title: '注释表单' }
      },
      {
        hidden:true,
        path: 'dataset_form',
        name: 'DatasetList_Form',
        component: () => import('@/views/Dataset/Form'),
        meta: { title: '数据集表单' }
      }
    ]
  },

  {
    path: '/bjyx',
    component: Layout,
    redirect: '/Application/List',
    name: 'bjyx',
    meta: { title: '何泳璇', icon: 'example' },
    children: [
      {   
        path: 'application',
        name: 'ApplicationList',
        component: () => import('@/views/Application/List'),
        meta: { title: '应用管理' }
      },
      {

        path: 'article',
        name: 'ArticleList',
        component: () => import('@/views/Article/List'),
        meta: { title: '文章管理' }
      },
      {
        path: 'baseconfig',
        name: 'BaseConfigList',
        component: () => import('@/views/BaseConfig/List'),
        meta: { title: '基本配置' }
      },
      {
        hidden:true,
        path: 'application_form',
        name: 'ApplicationList_Form',
        component: () => import('@/views/Application/Form'),
        meta: { title: '应用表单' }
      },
      {
        hidden:true,
        path: 'article_form',
        name: 'ArticleList_Form',
        component: () => import('@/views/Article/Form'),
        meta: { title: '文章表单' }
      },
      {
        hidden:true,
        path: 'baseconfig_form',
        name: 'BaseConfigList_Form',
        component: () => import('@/views/BaseConfig/Form'),
        meta: { title: '基本配置表单' }
      },
      {   
        hidden:true,
        path: 'article_content',
        name: 'ArticleList_Content',
        component: () => import('@/views/Article/Content'),
        meta: { title: '文章内容' }
      },
      {   
        path: 'foodrecognation',
        name: 'FoodRecognation_index',
        component: () => import('@/views/FoodRecognation/index'),
        meta: { title: '食物识别' }
      }
    ]
  },


  
 
  
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
